<#include "/common/pager_style/commonForm.ftl" encoding="UTF-8">
<script type="text/javascript" src="${request.contextPath}/resources/FCKeditor/fckeditor.js"></script>
<script type="text/javascript" src="${request.contextPath}/js/jquery/plugin/ajaxupload/ajaxfileupload.js"></script>
<script type="text/javascript" src="${request.contextPath}/js/jquery/zyplugin/appplugins/jquery.appPlugins.js"></script>
<script type="text/javascript" src="${request.contextPath}/js/ntkoocx.js"></script>
<script type="text/javascript" src="${request.contextPath}/week/deptDoc.js?version=201901083"></script>
<#-- 定义有哪些按钮 reset:重写 back:返回 -->
<#if editState="modify">
	<#if (!isHasSeal?exists || isHasSeal!="1")>
	<#assign buttonsName = {"submit":"提交","draftSave":"保存","seal":"盖章","back":"返回"}>
	<#else>
	<#assign buttonsName = {"submit":"提交","draftSave":"保存","reSeal":"重盖","back":"返回"}>
	</#if>
<#else>
	<#assign buttonsName = {"modify":"修改","back":"返回"}>
	<#--	如果需要特别的定义按钮的图片，请参照以下格式，不需要则请删除本行及下一行：	-->
	<#--	<#assign buttonsImage={"list":"refresh.gif","add":"add.gif"}>	-->
</#if>

<script language="JavaScript">
<!--
	var actName="weekRecordAction";
	var domainName="weekRecord";

	function showWord(){
		if($("#buttonSvrFile").val()=="显示正文"){
					$("#divTgContain").show();
					$("#wordBox").show();
					$("#divTgContain").contents().find("object").show();
					 $("#buttonSvrFile").val("隐藏正文");
			}else{
				$("#buttonSvrFile").val("显示正文");
				$("#divTgContain").hide();
				$("#wordBox").hide();
				$("#divTgContain").contents().find("object").hide();
			}
	}
	
	function checkForm(){
	    var strMsg = "";
		    var l = 0;
		    var l2 = 0;
			var l3 = 0;
		    if(typeof($("#weekRecord\\.title").val())=="string"){
		    	  l = $("#weekRecord\\.title").val().length;
		    }
		    if(typeof($("#weekRecord\\.returnRemark").val())=="string"){
		    	  l2 = $("#weekRecord\\.returnRemark").val().length;
		    }
		     if(typeof($("#weekRecord\\.remark").val())=="string"){
		    	  l3 = $("#weekRecord\\.remark").val().length;
		    }
			//类型：AlphaNumeric,Date,Email,Empty,Numeric,Money,PostalCode,Url
			strMsg = strMsg + Validate( "weekRecord.title", "标题","NotEmpty");
			strMsg = strMsg + Validate( "weekRecord.expectTime", "限时日期","NotEmpty");
			strMsg = strMsg + Validate( "weekRecord.swUnit.id", "主办单位","NotEmpty");
			
			if($("#weekRecord\\.formCode").val()=="zdbgy"&&$("#editState").val()=='modify'){
				strMsg = strMsg + Validate( "weekRecord.swLeader.id", "分管领导","NotEmpty");
			}
			
			if(l>70){
				alert( "标题不能大于70个字符！");
				return false;
			}
			if(l2>1000){
				alert( "备注不能大于1000个字符！");
				return false;
			}
			if(l3>500){
				alert( "部门意见不能大于500个字符！");
				return false;
			}
			if( strMsg != "" )
			{
				alert( strMsg );
				return false;
			}
			else{
			return true;
			}
	}

	$(function() {
		$("form").validationEngine({alertShow:true}); //表单验证
	});
	
	//表单提交
	function opt_submit(){
		if($("#isSeal").val()=="0"){
			if(!confirm("盖章尚未提交,是否继续保存？")){
				return ;
			}
		}
		docFileType="ZW";
		saveDocFile();
		setTimeout(function(){
			$("form").eq(0).attr("action",actName + '!submitSave.shtml');
			$("form").eq(0).submit()
			}
		,500);
	}
	
	function opt_draftSave(){
	
		if($("#isSeal").val()=="0"){
			if(!confirm("盖章尚未提交,是否继续保存？")){
				return ;
			}
		}
		docFileType="ZW_DRAFT";
		saveDocFile();
		$("#isDraftSave").val('1');
		
		$("form").eq(0).attr("action",actName + '!draftSave.shtml');
		$("form").eq(0).submit();
	}
	
	
	
	
	
	
	
	
	//主办所有单位打开openReference
	function openPerAllMainUnit(){
	//	$("#buttonSvrFile").val("显示正文");
	//	$("#divTgContain").hide();
	//	$("#wordBox").hide();
	//	$("#divTgContain").contents().find("object").hide();
	
		var seleObjId ="swUnitTypeValue"
		var valueEleId = "weekRecord\\.swUnit\\.id";
		var titleEleId = "weekRecord\\.swUnit\\.name";
		seleObjId = seleObjId.replace(".","\\.");
		var type = $('#' + seleObjId).val();
		var rtn = valueEleId + '=value1&' + titleEleId + '=value2';
		
		//openReferenceM('SysDept', 'showEditDeptTreeAll', rtn);
			openReferenceM('sysOrg','getOrg',rtn);
	}
	
	function changeDate(date){
		if(date.value==3){
			$("#weekRecord\\.expectTime").val($("#nowDateAddThree").val())
		}else if(date.value==5){
			$("#weekRecord\\.expectTime").val($("#nowDateAddFive").val())
		}else if(date.value==7){
			$("#weekRecord\\.expectTime").val($("#nowDateAddSeven").val())
		}	
	}
	
	function openswLeader(){
	openReference('WeekRecord','fgLeader','weekRecord.swLeader.id=value1&weekRecord.swLeader.userName=value2&inParams=${(fgLeaderIds)?if_exists}');
 }
//-->
</script>
</head>
<body scroll="auto">
<div class="topDiv">
	<#include "/common/pager_style/pageButtonsEx.ftl" encoding="UTF-8">
</div><!-- end #topDiv -->
<div id="mainDiv">
	<div id="centerDiv" style="bottom:31px">
		<div id="body">
<#-- 修改：form的名字 -->
<form name="dictALForm" action="" method="post" onsubmit="return checkForm();">
	<input type="hidden" id="id" name="id" value="${(weekRecord.id)?if_exists}"/>
	<input type="hidden" name="page.offset" id="page.offset" value="${(page.offset)?if_exists}" >
	<input type="hidden" name="page.pageSize" id="page.pageSize" value="${(page.pageSize)?if_exists}">
	<input type="hidden" name="weekFormId" id="weekFormId" value="${(weekFormId)?if_exists}">
	<#--weekRecord参数-->
	<input type="hidden" id="weekRecord.id" name="weekRecord.id" value="${(weekRecord.id)?if_exists}"/>
	<input type="hidden" id="weekRecord.formCode" name="weekRecord.formCode" value="${(weekRecord.formCode)?if_exists}"/>
	<input type="hidden" id="weekRecord.firstCreateTime" name="weekRecord.firstCreateTime" value="${(weekRecord.firstCreateTime)?if_exists}"/>
	<input type="hidden" id="weekRecord.lwDocDataId" name="weekRecord.lwDocDataId" value="${(weekRecord.lwDocDataId)?if_exists}"/>
	<input type="hidden" id="weekRecord.zwDataId" name="weekRecord.zwDataId" value="${(weekRecord.zwDataId)?if_exists}"/>
	<input type="hidden" id="weekRecord.swDocDataId" name="weekRecord.swDocDataId" value="${(weekRecord.swDocDataId)?if_exists}"/>
	<input type="hidden" id="weekRecord.createTime" name="weekRecord.createTime" value="${(weekRecord.createTime)?if_exists}"/>
	
	<#--其他参数-->
	<input type="hidden" name="editState" id="editState" value="${(editState)?if_exists}">
	<input type="hidden" name="swUnitTypeValue" id="swUnitTypeValue" value="ORG_SYS">
	<input type="hidden" name="sfbTypeValue" id="sfbTypeValue" value="ORGS_SYS">
	<input type="hidden" name="isDraftSave" id="isDraftSave" value="${(isDraftSave)?if_exists}">
	<input type="hidden" name="isDraft" id="isDraft" value="${(isDraft)?if_exists}">
	<input type="hidden" name="nowDateAddFifteen" id="nowDateAddFifteen" value="${(nowDateAddFifteen)?if_exists}">
	<input type="hidden" name="nowDateAddSeven" id="nowDateAddSeven" value="${(nowDateAddSeven)?if_exists}">
	<input type="hidden" name="nowDateAddFive" id="nowDateAddFive" value="${(nowDateAddFive)?if_exists}">
	<input type="hidden" name="nowDateAddThree" id="nowDateAddThree" value="${(nowDateAddThree)?if_exists}">
	<input type="hidden" name="nowDateAddTwo" id="nowDateAddTwo" value="${(nowDateAddTwo)?if_exists}">	
	<#--正文-->
	<#--		当前用户相关信息		-->
	<input type="hidden" name="cur_userId" 			id="cur_userId" 			value="${(currentUser.id)?if_exists}"/>
	<input type="hidden" name="cur_userCode" 		id="cur_userCode" 			value="${(currentUser.code)?if_exists}"/>
	<input type="hidden" name="cur_userName" 		id="cur_userName" 			value="${(currentUser.name)?if_exists}"/>
	<input type="hidden" name="cur_fullName" 		id="cur_fullName" 			value="${(currentUser.fullName)?if_exists}"/>
	<input type="hidden" name="cur_deptId" 			id="cur_deptId" 			value="${(currentUser.deptId)?if_exists}"/>
	<input type="hidden" name="cur_deptName" 		id="cur_deptName" 			value="${(currentUser.deptName)?if_exists}"/>
	<input type="hidden" name="cur_fullDeptName"	id="cur_fullDeptName" 		value="${(currentUser.fullDeptName)?if_exists}"/>
	<input type="hidden" name="cur_roleCodes"		id="cur_roleCodes" 			value="${convertArrayToString(currentUser.roleCodes)}"/>
	<input type="hidden" name="cur_groupCodes"		id="cur_groupCodes" 		value="${convertArrayToString(currentUser.groupCodes)}"/>
	<input type="hidden" name="cur_orgId"		    id="cur_orgId" 		        value="${(currentUser.orgId)?if_exists}"/>
	<input type="hidden" name="cur_orgName"		    id="cur_orgName"			value="${(currentUser.orgName)?if_exists}"/>
	<input type="hidden" name="cur_fullOrgName"		id="cur_fullOrgName"		value="${(currentUser.fullOrgName)?if_exists}"/>
	<input type="hidden" name="cur_orgDeptRootId" 	id="cur_orgDeptRootId"		value="${(currentUser.orgDeptRootId)?if_exists}"/>
    <input type="hidden" name="cur_orgDeptRootName" id="cur_orgDeptRootName" 	value="${(currentUser.orgDeptRootName)?if_exists}"/>
    <input type="hidden" name="cur_s3" 			id="cur_s3" 			value="${(currentUser.s3)?if_exists}"/>
	<#--		当前日期、时间等信息	-->
	<input type="hidden" name="cur_now"				id="cur_now" 				value="${(currentUser.now)?if_exists}"/>
	<input type="hidden" name="cur_date"			id="cur_date" 				value="${(currentUser.date)?if_exists}"/>
	<input type="hidden" name="cur_time"			id="cur_time" 				value="${(currentUser.time)?if_exists}"/>
	    <#--   查看该流程是否有盖过章(天谷)的版式文件 -->
    <input type="hidden" name="isHasSeal" id="isHasSeal" value="${(isHasSeal)?if_exists?string}"	/>
    <input type="hidden" name="sealPdfId" id="sealPdfId" value="${(sealPdfId)?if_exists?string}"	/>
    <input type="hidden" name="canSealPdfId" id="canSealPdfId" value="${(canSealPdfId)?if_exists?string}"	/>
    <#-- 路径参数 -->
    <input type="hidden" name="pathParam" 			id="pathParam" 			value="${(request.contextPath)?if_exists}"/>
	<#-- 其他参数 -->
	<input type="hidden" name="code" id="code" value="${(code)?if_exists}">
	<input type="hidden" name="lwCode" id="lwCode" value="${(lwCode)?if_exists}">
	<input type="hidden" name="isLoad" id="isLoad" value="">
	<input type="hidden" name="isSeal" id="isSeal" value="">
	<input type="hidden" name="isToSeal" id="isToSeal" value="">
	<input type="hidden" name="codeList" id="codeList" value="${(codeList)?if_exists}">

	<table class="tbl fix">
		<caption><#if (entityTitle)?exists>${(entityTitle)?if_exists}</#if></caption>
		<tbody>
		<tr>
			<td>
				<table class="tbl">
					<tbody>
						<@pEdit.pageEditText
							label="标题*"
							pageState="${editState}"
							attName="weekRecord.title"
							validate="validate[maxSize[200]]"
							attValue="${(weekRecord.title)?if_exists}"/>
						<@pEdit.pageEditText
							label="文号"
							pageState="${editState}"
							attName="weekRecord.docNum"
							validate="validate[maxSize[40]]"
							attValue="${(weekRecord.docNum)?if_exists}"/>
						<@pEdit.pageEditText
							label="创建人"
							pageState=""
							beginTR="true"
							endTR="false"
							colSpanNum="1"
							inputReadOnly="true"
							attName="currentUser.name"
							attValue="${(currentUser.name)?if_exists}"
							/>	
					<input type="hidden" id="weekRecord.createBy.id" name="weekRecord.createBy.id" value="${(weekRecord.createBy.id)?if_exists}"/>			
					 <@pEdit.pageEditText
							label="来文单位*"
							pageState=""
							attName="weekRecord.lwUnit.name"
							validate="validate[maxSize[12]]"
							attValue="${(weekRecord.lwUnit.name)?if_exists}"/>
					<input type="hidden" name="weekRecord.lwUnit.id" id="weekRecord.lwUnit.id" value="${(weekRecord.lwUnit.id)?if_exists}">
					<#if weekRecord.formCode="zdyxq">
					 <@pEdit.pageEditTextarea
							label="主办单位*"
							pageState="${editState}"
							attName="weekRecord.swUnit.name"
							validate="validate[maxSize[12]]"
							showRefer="true"
							referJS="selectUsersForType('swUnitTypeValue','weekRecord\\.swUnit\\.id','weekRecord\\.swUnit\\.name');return false;"
							attValue="${(weekRecord.swUnit.name)?if_exists}"/>						
						<input type="hidden" name="weekRecord.swUnit.id" id="weekRecord.swUnit.id" value="${(weekRecord.swUnit.id)?if_exists}">
					<#else>
						<@pEdit.pageEditText
								label="主办单位*"
								pageState=""
								attName="weekRecord.swUnit.name"
								validate="validate[maxSize[12]]"
								attValue="${(weekRecord.swUnit.name)?if_exists}"/>
						<input type="hidden" name="weekRecord.swUnit.id" id="weekRecord.swUnit.id" value="${(weekRecord.swUnit.id)?if_exists}">				
					</#if>
					<#if weekRecord.formCode="zdbgy">
						<th>
							<label for="weekRecord.swLeader.id">分管领导*<a href="#" onchange="" onClick="openswLeader()" title="点击指定人员范围"> >></a></label><br>
						</th>
						<td  height="10px" colspan="1">
						<textarea name="weekRecord.swLeader.userName" class="txt_readonly" id="weekRecord.swLeader.userName" onClick="openswLeader()"   style = "width:100%;height:20px;line-height:20px;" readonly  >${(weekRecord.swLeader.userName)?if_exists}</textarea>
						<input type="hidden" name="weekRecord.swLeader.id" id="weekRecord.swLeader.id" value="${(weekRecord.swLeader.id)?if_exists}">
						</td>	
					</#if>
			
					<#if (!isHasSeal?exists || (isHasSeal!="1"&&isHasSeal!="2"))>
						<@pEdit.pageEditTextarea
							label="协办单位"
							pageState="${editState}"
							attName="weekRecord.coOperationUnitNames"
							validate="validate[maxSize[12]]"
							showRefer="true"
							referJS="selectUsersForType('sfbTypeValue','weekRecord\\.coOperationUnitIds','weekRecord\\.coOperationUnitNames');return false;"
							attValue="${(weekRecord.coOperationUnitNames)?if_exists}"/>						
					<#else>
						<@pEdit.pageEditTextarea
								label="协办单位2"
								pageState=""
								attName="weekRecord.coOperationUnitNames"
								validate="validate[maxSize[12]]"
								showRefer="true"
								attValue="${(weekRecord.coOperationUnitNames)?if_exists}"/>						
					</#if>
					<input type="hidden" name="weekRecord.coOperationUnitIds" id="weekRecord.coOperationUnitIds" value="${(weekRecord.coOperationUnitIds)?if_exists}">		
						<th>
							<span><label for="weekRecord.expectTime">办理时限</label></span>
						</th>
						<td colspan="3">
							<input type="text" name="weekRecord.expectTime" class="datePicker " id="weekRecord.expectTime"  onclick="WdatePicker({errDealMode:1,dateFmt:'yyyy-MM-dd HH:mm:ss'});" size="20" style="width:145px;" value="${(weekRecord.expectTime)?if_exists}"   >					
							<input type="radio" name="timeLimit" class="inputRadio" id="timeLimit_0" onclick="changeDate(this)" style="width:20px;" value="3" checked="" title="三天">
									<label for="timeLimit_0">三天</label>
								<input type="radio" name="timeLimit" class="inputRadio" id="timeLimit_1" onclick="changeDate(this)" style="width:20px;" value="5" title="五天">
									<label for="timeLimit_1">五天</label>
								<input type="radio" name="timeLimit" class="inputRadio" id="timeLimit_2" onclick="changeDate(this)" style="width:20px;" value="7" title="七天">
									<label for="timeLimit_2">七天</label>
								<input type="radio" name="timeLimit" class="inputRadio" id="timeLimit_3" onclick="changeDate(this)" style="width:20px;" value="9" checked="" title="默认">
									<label for="timeLimit_3">默认</label>	
						</td>
						
					<tr>
						<th>
							<span><label for="weekRecord.emergercyDegree">缓急程度</label></span>
						</th>
							<td  colspan="1" >
								<input type="radio" name="weekRecord.emergercyDegree" class="inputRadio" id="weekRecord.emergercyDegree_0"   value="1" checked  title="常规" >
									<label for="weekRecord.emergercyDegree_0">常规</label>
								<input type="radio" name="weekRecord.emergercyDegree" class="inputRadio" id="weekRecord.emergercyDegree_1"   value="2"   title="加急" >
									<label for="weekRecord.emergercyDegree_1">加急</label>
								<input type="radio" name="weekRecord.emergercyDegree" class="inputRadio" id="weekRecord.emergercyDegree_2"   value="3"   title="紧急" >
									<label for="weekRecord.emergercyDegree_2">紧急</label>
								<input type="radio" name="weekRecord.emergercyDegree" class="inputRadio" id="weekRecord.emergercyDegree_3"   value="4"   title="特急(即时办理)" >
									<label for="weekRecord.emergercyDegree_3">特急(即时办理)</label>
							</td>	
					</tr>			
						</tbody>			
					</table>
				</td>
			</tr>
		</tbody>
	</table>
	<!--正文str-->
	  <div style="padding-left:21px">
        <input type='button' style = "font-size:15px" id="buttonSvrFile" value="隐藏正文" onclick="showWord();return false;">
       		</div>
         <div  id='wordBox'>
          <#if (!isHasSeal?exists || (isHasSeal!="1"&&isHasSeal!="2"))>
        <div  id='wordFile'>
		<a name="#word"></a>
		<#-- 导入word控件 -->
		<#include "/common/wordcontrol.ftl" encoding="UTF-8"/>
		</div>
		<#else>
			<iframe border=0 id='divTgContain' src="./workflow/jet/TGPDFPlugInCtrlView.htm" width='100%' height='850px' ></iframe>
		</#if>
	</div>
	<!--正文end-->
	<!--附件str-->
<div align="center" id="divAttachments">
					<fieldset class="fieldAttachment" style="text-align:left;">
				    	<legend>
								附件管理
						</legend>
						<div id="_attachments1" style="float:left;margin-left:20px;">
						</div>
					</fieldset>
					<script type="text/javascript">
					<!--
						$(document).ready(function(){
							var $attach=$("#_attachments1");
							// 生成供下载的附件及上传功能
							//防止使用dialog弹出页面时再次执行该代码又生成了上传附件
							var isCreated=$attach.attr("isCreated");
							var eventOptions = {	// 定义uploadify对象的定制事件
							};
							if(isEmpty(isCreated) || isCreated!="true"){
								$attach.showAddAttachment("WEEK_RECORD",${(weekRecord.lwDocDataId)?if_exists},"","*.*",true,true,eventOptions);
								$attach.attr("isCreated","true");
							}
						});
					//-->
					</script>		
			</div>
	<!--附件end-->
	</div><!-- end #body -->
	</div><!-- end #centerDiv -->
</div><!-- end #mainDiv -->
</form>
<input type="hidden" id="moveGroup" value="" onChange="changeGroup();">
</body>
</html>